<?php 

include "../functions.php";

try{
	$dsn = "mysql:host=127.0.0.1;dbname=zuoye";
	$pdo = new Pdo($dsn,"root","");
	//设置字符集
	$pdo->query("set names utf8");
	//错误属性
	$pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
	//开始准备，返回对象
	$state = $pdo->prepare("select * from student where age>? and sex=?");
	$age = 28;
	$sex = "女";
	//绑定参数
	$state->bindParam(1,$age,PDO::PARAM_INT);
	$state->bindParam(2,$sex,PDO::PARAM_STR);
	//执行
	$state->execute();
	//接收
	$rows = $state->fetchAll(PDO::FETCH_ASSOC);
	p($rows);
	
}catch(PDOException $e){
    die($e->getMessage());
}




